<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="demo.model.StudentInfo,demo.dal.Student"%>
<%
	request.setCharacterEncoding("utf-8"); //中文数据不会出现乱码
	StudentInfo info=new StudentInfo(); //创建demo.model.StudentInfo的对象info
	Student student = new Student(); //创建demo.dal.Student的对象student
	//如果获得参数action的值为add ，则表示，操作者已经点击了“提交”按钮，那么将执行下面代码实现数据保存
	if ("add".equals(request.getParameter("action"))  )  
	{                                                     
    	info.setNumber(request.getParameter("number"));
		info.setName(request.getParameter("name"));
		info.setSex(request.getParameter("sex"));
		info.setAddress(request.getParameter("address"));
		info.setPhone(request.getParameter("phone"));
		info.setEmail(request.getParameter("email"));
		student.insert(info); //通过student对象调用 insert方法，实现数据保存
	}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head> 
    <title>数据添加</title>
  </head>
  
  <body>
  <!-- 注意form标签的action属性值  -->
		<form id="form1" name="form1" method="post" action="insert.jsp?action=add">
			<table width="384" height="289" border="1">
				<tr>
					<td>学号</td>
					<td><input type="text" name="number" id="number" /></td>
				</tr>
				<tr>
					<td>姓名</td>
					<td><input type="text" name="name" id="name" /></td>
				</tr>
				<tr>
					<td>性别</td>
					<td>
						<input type="radio" name="sex" id="sex" value="男" checked/> 男
						<input type="radio" name="sex" id="sex" value="女" /> 女
					</td>
				</tr>
				<tr>
					<td>住址</td>
					<td><input type="text" name="address" id="address"/></td>
				</tr>
				<tr>
					<td>电话</td>
					<td><input type="text" name="phone" id="phone" /></td>
				</tr>
				<tr>
					<td>邮箱</td>
					<td><input type="text" name="email" id="email" /></td>
				</tr>
				<tr>
					<td colspan="2"><input type="submit" name="button" id="button" value="提交" />
						<input type="reset" name="button2" id="button2" value="重置" />
					</td>
				</tr>
			</table>
		</form>
	</body>
</html>